package algo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import sudoku.SudokuEinzelfeld;

public class CountSets {

	public Map<Set<Integer>, Integer> countSets(List<SudokuEinzelfeld> struct, Set<Set<Integer>> sets){
		Map<Set<Integer>, Integer> countMap = new HashMap<Set<Integer>, Integer>();
		for (SudokuEinzelfeld sudokuEinzelfeld : struct) {
			Set<Integer> possNrs = sudokuEinzelfeld.getPossibleNumbers();
			System.out.println("Possnr: " + possNrs);
			for (Set<Integer> setInts : sets) {
				if(possNrs.equals(setInts)){
					insertInMap(countMap, setInts);
				}
			}
		}
		return countMap;
	}

	private void insertInMap(Map<Set<Integer>, Integer> countMap,
			Set<Integer> setInts) {
		if(countMap.containsKey(setInts)){
			int counter = countMap.get(setInts);
			countMap.put(setInts, ++counter);
		} else {
			countMap.put(setInts, 1);
		}
	}
	
}
